package org.mtmi.ui.controls;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.mtmi.ui.M;
import org.mtmi.ui.layouts.LayoutData;
import org.mtmi.ui.scenes.COLOR;
import org.mtmi.ui.scenes.Scene;

/**
 * control made to visually separate actions
 */
public class ToolBarSeparator extends Control
{
	/** use M.HORIZONTAL or M.VERTICAL, the direction of separator line */
	public ToolBarSeparator( Scene scene, int flags) {
		super(scene, flags);
		setForeground( COLOR.grey20 );
		setSize( computeSize( new LayoutData(scene) ) );
	}

	@Override
	public Point computeSize(LayoutData l) {
		return new Point( 10, 10 ); //by default
	}

	@Override
	public void paint( GC gc ) {
		
		gc.setLineWidth( 3 );
		gc.setForeground( getForeground() );
		
		boolean vert = (getFlags() & M.VERTICAL) !=0;
		if( vert ) {
			int x = location.x+size.x/2;
			gc.drawLine( x, location.y, x, location.y+size.y );
		} else {
			int y = location.y+size.y/2;
			gc.drawLine( location.x, y, location.x+size.x, y );
		}
	}

}
